package HighMethod02;

/**
 * 求集合的子集
 */
public class test02 {

    public static void main(String[] args) {
        int arr[] = {1, 2, 3};
        int brr[] = {0, 0, 0};
        Fun(arr, brr, 0, arr.length);
    }

    /**
     * 抽象为二进制数对应的bit位，为1即输出
     * @param arr
     * @param brr
     * @param i
     * @param m
     */
    private static void Fun(int[] arr, int[] brr, int i, int m) {

        if (i >= m) {
            for ( int k = 0;k< m;k++){
                if(brr[k] == 1){
                    System.out.print(arr[k] +" ");
                }
            }
            System.out.println();

        } else {
            brr[i] = 1;
            Fun(arr, brr, i + 1, m);
            brr[i] = 0;
            Fun(arr, brr, i + 1, m);
        }

    }
}
